﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";
    var roles = ManagerAuthorization.Current.User.Roles;
    var key = Request["key"];// 汽湃号栏目
}
@section Toolbar
{
    @if (roles.Any(x => x.Key == "QPHSH") && key == "qphgl")
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "修改", Click = "modify" })
    }
    else if (roles.Any(x => x.Key == "QPHSH"))
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "新建", Click = "create" })
        @Html.MyNet().Button(new ButtonOptions { Text = "修改", Click = "modify" })
        if (ConvertHelper.ToBoolean(Request["showSignup"]))
        {
            @Html.MyNet().Button(new ButtonOptions { Text = "报名信息", Click = "signup" })
        }
        @Html.MyNet().Button(new ButtonOptions { Text = "删除", Click = "removee" })
    }
    else
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "新建", Click = "create" })
        @Html.MyNet().Button(new ButtonOptions { Text = "修改", Click = "modify" })
        if (!roles.Any(x => x.Key == "Admin_YG"))
        {
            @Html.MyNet().Button(new ButtonOptions { Text = "审核通过", Click = "pass" })
            @Html.MyNet().Button(new ButtonOptions { Text = "审核不通过", Click = "unPass" })
        }
        @Html.MyNet().Button(new ButtonOptions { Text = "移动", Click = "move" })
        @Html.MyNet().Button(new ButtonOptions { Text = "置顶", Click = "setTop" })
        @Html.MyNet().Button(new ButtonOptions { Text = "上移", Click = "moveUp" })
        @Html.MyNet().Button(new ButtonOptions { Text = "下移", Click = "moveDown" })
        if (ConvertHelper.ToBoolean(Request["showSignup"]))
        {
            @Html.MyNet().Button(new ButtonOptions { Text = "报名信息", Click = "signup" })
        }
        @Html.MyNet().Button(new ButtonOptions { Text = "删除", Click = "removee" })
    }
}
@section Menu
{
    @if (roles.Any(x => x.Key == "QPHSH"))
    {
        @Html.MyNet().Menu(new ButtonOptions { Text = "修改", Click = "modify" })
    }
    else
    {
        @Html.MyNet().Menu(new ButtonOptions { Text = "修改", Click = "modify" })
        @Html.MyNet().Menu(new ButtonOptions { Text = "移动", Click = "move" })
        @*@Html.MyNet().Menu(new ButtonOptions { Text = "转链", Click = "transfer" })*@
        if (!roles.Any(x => x.Key == "Admin_YG"))
        {
            @Html.MyNet().Menu(new ButtonOptions { Text = "审核通过", Click = "pass" })
            @Html.MyNet().Menu(new ButtonOptions { Text = "审核不通过", Click = "unPass" })
        }
        @Html.MyNet().Menu(new ButtonOptions { Text = "删除", Click = "removee" })
    }
}
@section Query
{
    @Html.Partial("_Query", new ArticleCondition())
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
    @Html.Hidden("CatalogKey", Request["key"])
}
<script type="text/javascript">

    var url = "/CMS/Article/";
    var urlSignup = "/CMS/Signup/";

    jQuery(function () {
        read();
    });

    function read() {
        query.CatalogKey = $("#CatalogKey").val();
        $.ajax
            ({
                url: url + "Read",
                data: query,
                type: "post",
                error: disposeError,
                success: function (result) {

                    if (disposeException(result)) return;
                    bind(result);
                }
            });
    }

    function create() {
        nav(url + "Create?CatalogKey=" + $("#CatalogKey").val());
    }

    function modify() {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Modify?Id=" + gridSelected());
    }

    function move() {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Move?Ids=" + gridSelected().join(','));
    }

    function transfer() {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Transfer?Ids=" + gridSelected().join(','));
    }

    function comment() {
        var commentCatalogKey = gridSelectedHidden("CommentCatalogKey");
        if (commentCatalogKey.toString().length == 0) return alert("该栏目未配置所评论栏目！");

        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Comment?Id=" + gridSelected());
    }

    function associate() {
        var associationCatalogKey = gridSelectedHidden("AssociationCatalogKey");
        if (associationCatalogKey.toString().length == 0) return alert("该栏目未配置所关联信息栏目！");

        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Association?AssociationId=" + gridSelected());
    }

    function removee() {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
            ({
                url: url + "Remove",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;

                    read();
                }
            });
    }

    function pass() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "Pass",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;

                    read();
                }
            });
    }

    function unPass() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "UnPass",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function setTop() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "SetTop",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function moveUp() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "MoveUp",
                data: { id: gridSelected()[0] },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function moveDown() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "MoveDown",
                data: { id: gridSelected()[0] },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function signup() {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(urlSignup + "index?articleId=" + gridSelected());
    }
</script>
